#include <cstdio>
#include <algorithm>

using namespace std;

bool cmp(int a, int b) {
	return a > b;
}

int main() {
	const int MAX = 100;
	bool flag[MAX+10] = {false};
	int n, num[MAX+10], r[MAX+10], j = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &num[i]);
		flag[num[i]] = true;
	}

	for (int i = 0; i < n; i++) {
		while (num[i] != 1) {
			if (num[i] % 2 == 0) num[i] /= 2;
			else num[i] = (num[i] * 3 + 1) / 2;
			if (flag[num[i]]) {
				flag[num[i]] = false;
			}
		}
	}

	for (int i = 0; i < MAX; i++) {
		if (flag[i])
			r[j++] = i;
	}
	sort(r, r+j, cmp);
	for (int i = 0; i < j; i++) {
		printf("%d%c", r[i], i==j-1?'\n':' ');
	}
	return 0;

